﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EasyCLRBase
{
    /// <summary>
    /// Contains information about given assembly
    /// </summary>
    public class AssemblyInfo : IEquatable<AssemblyInfo>
    {
        /// <summary>
        /// Get the location of the Assembly.
        /// </summary>
        public String Path
        {
            get;
            private set;
        }
        /// <summary>
        /// Get the Name of the Assembly
        /// </summary>
        public String Name
        {
            get;
            private set;
        }

        public AssemblyInfo(System.Reflection.Assembly assembly)
        {
            this.Name = assembly.GetName().Name;
            this.Path = assembly.Location;
        }

        public override int GetHashCode()
        {
            return HashBuilder.GetHashCode(this.Path, this.Name);
        }

        public override bool Equals(object obj)
        {
            return this.Equals((obj as AssemblyInfo));
        }
        /// <summary>
        /// Equality check.
        /// </summary>
        /// <param name="other">Other Assembly information</param>
        /// <returns>True if other and self are equals</returns>
        public bool Equals(AssemblyInfo other)
        {
            return other == null ? false : String.Equals(this.Name, other.Name) && String.Equals(this.Path, other.Path);
        }
    }
}
